﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Microsoft Corp." file="DeploymentProgress.cs">
//   All rights reserved. See License.txt in the project root for license information.
// </copyright>
// 
// --------------------------------------------------------------------------------------------------------------------
namespace CloudBlitz.DeploymentManager
{
    using System.Web.Script.Serialization;

    public class DeploymentProgress
    {
        public DeploymentProgress(int progress, string message, DeploymentState state)
        {
            this.Progress = progress;
            this.Message = message;
            this.State = state.ToString();
        }

        public int Progress { get; private set; }

        public string Message { get; private set; }

        public string State { get; private set; }

        public static DeploymentProgress DeserializeFromJson(string representation)
        {
            var serializer = new JavaScriptSerializer();
            return serializer.Deserialize<DeploymentProgress>(representation);
        }

        public string SerializeToJson()
        {
            var serializer = new JavaScriptSerializer();
            return serializer.Serialize(this);
        }
    }
}